export default {
	common: {
		baseUrl: "http://192.168.1.102:3000/api",
		data: {},
		header: {
			'content-type': 'application/json',
			'content-type': 'application/x-www-form-urlencoded',
		},
		method: "GET",
		dataType: "json"
	},
	request(options = {}) {
		uni.showLoading({
			title:'加载中'
		});
		
		options.url = this.common.baseUrl + options.url;
		options.data = options.data || this.common.data;
		options.header = options.header || this.common.header;
		options.method = options.method || this.common.method;
		options.dataType = options.dataType || this.common.dataType;
		return new Promise((resolve, reject) => {
			uni.request({
				...options,
				/* url: this.common.baseUrl + options.url,
				method: options.method || this.common.method,
				data: options.data || this.common.dataType, */
				success: (result) => {
					// console.log(result);
					if (result.statusCode != 200) {
						// console.log('获取数据失败');
						return reject(); //uni.showToast({title: '获取数据失败'})
					}
					let data = result.data.data;
					// console.log(data);
					resolve(data);
					setTimeout(function () {
						uni.hideLoading();
					}, 500);
				},
				fail: (err) => {
					console.log(err);
					uni.showToast({
						title: '请求接口失败'
					})
					reject(err)
				}
			})
		})
	}
}
// export default 